// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import { XHeader } from 'vux'
import App from './App'
import router from './router'
// import "./common/fontSize.js"
import 'lib-flexible'
//
import store from './store'
// 轻量的http请求库
// import VueResource from 'vue-resource'
// Vue.use(VueResource)
import api from './api/ApiURL'
import http from './api/Http'

Vue.config.productionTip = false
// 全局记录上层路由名，处理返回动画
Vue.prototype.fromRouterName = '';

Vue.prototype.api = api;
Vue.prototype.http = http;
// Vue.config.errorHandler = function (err, vm, info) {
//   var router = vm.$route.name
//   alert('errorHandler:  ' + JSON.stringify(err) + '--------- currentRouter: ' + router)
// }

/* eslint-disable no-new */

Vue.component('x-header', XHeader)
// Vue.http.interceptors.push((request, next) => {
//   // setting request.headers
//   // request.headers.set('Access-Control-Allow-Origin', '*')
//   // request.headers.set('Content-Type', 'image/jpeg')
//   next(function (response) {
//     // alert(JSON.stringify(response))
//     // 做拦截处理
//     // setting request.headers
//     return response
//   })
// })

var app = new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

document.addEventListener('backbutton', onBackKeyDown, false)

function onBackKeyDown () {
//   alert('back1')
}
